package corejava;

/**
 * 把1-n这n个自然数连续排列在一起，问这个字符串有多长
 * n<=100
 * n<=100000
 * n<=10000000
 * <p>
 * O(n!)>O(2^n)>O(n^3) >O(n^2)>O(nlogn) >O(n) >O(sqrt(n)) > O(log(n))  > O(1)
 */
public class JoinNumbers1 {//O(n)

    public static void main(String[] args) {
        int n = 40000;
        long start = System.currentTimeMillis();//计时器
        StringBuffer buffer = new StringBuffer();
        for (int i = 1; i <= n; i++) {
            buffer.append(Integer.toString(i));
        }
        System.out.println(buffer.length());

        long end = System.currentTimeMillis();//计时

        double cost = (end - start) / 1000.0;
        System.out.println(cost + " Second(s).");

    }
}
